import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './styles/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { loadRoutesFromAPI } from './router/dynamic'
import permissionDirective from './utils/permission'
import App from './App.vue'
import router from './router'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(createPinia())
  // 等接口路由加载完毕并注册
await loadRoutesFromAPI()
app.directive('permission', permissionDirective)
app.use(router)
app.use(ElementPlus,{
  locale: zhCn,
})

app.mount('#app')
